import dt from '@dt/dt'
import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'

function targetColumns(_this) {
  let vm = _this
  let head = [{
      field: 'monthDesc',
      title: '执行周期',
      fixed: 'left',
      minWidth: 130
    },
    {
      field: 'auditStatusDesc',
      title: '审核状态',
      minWidth: 130,
      slots: {
        default: (params, h) => {
          return [h('div', params.row.auditStatusDesc)]
        }
      }
    },
    {
      title: '营销成本（元）',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatterMoney(params.row.targetMarketCost))]
        }
      }
    },
    {
      title: '目标线索',
      minWidth: 130,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatNumtoLocaleString(params.row.targetClue))]
        }
      }
    },
    {
      title: '目标来人',
      minWidth: 130,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatNumtoLocaleString(params.row.targetVisit))]
        }
      }
    },
    {
      title: '目标认购套数',
      minWidth: 130,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatNumtoLocaleString(params.row.targetSubscribe))]
        }
      }
    },
    {
      title: '目标签约套数',
      minWidth: 130,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatNumtoLocaleString(params.row.targetSign))]
        }
      }
    },
    {
      title: '目标签约面积（m²）',
      minWidth: 170,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatterMoney(params.row.targetSignArea))]
        }
      }
    },
    {
      title: '目标签约金额（元）',
      minWidth: 170,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatterMoney(params.row.targetSignAmount))]
        }
      }
    },
    {
      field: 'createUser',
      title: '创建人',
      minWidth: 100,
    },
    {
      field: 'createDate',
      title: '创建日期',
      minWidth: 170,
      slots: {
        default: (params, h) => {
          return [h('div', vm.$tool.formatterDate(params.row.createDate))]
        }
      }
    },
    {
      field: 'handles',
      title: '操作',
      width: 130,
      align: 'center',
      fixed: 'right',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'ivewAudit',
            data: {
              row: params.row,
              type: 1
            }
          })
          if (vm.curState == 'waitAudit' && vm.unlocking('0107070301')) {
            btns.push({
              title: '审核',
              event: 'ivewAudit',
              data: {
                row: params.row,
                type: 2
              }
            })
          }
          return table.cell.btns(_this, h, btns)
        }
      }
    },
  ]
  return head
}

function targetOptions() {
  let options = {
    type: '', // form类型  Input / DatePicker / Checkbox / Select / 操作配置头部
    placeholder: '', // 提示语
    left: -1000, // 弹框fixed => left
    iconLeft: 0, // 弹框icon => left
    top: -1000, // 弹框fixed => top
    width: 218, // 弹框fixed => top
    setTimeout: null, // 鼠标离开三角形 200毫秒 关闭弹框
    createName: ''
  }
  return options
}
export default {
  targetColumns,
  targetOptions
}